﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GJK3DMain : MonoBehaviour
{
    [Header("方块")]
    public MeshFilter Target_1;

    [Header("圆形")]
    public MeshFilter Target_2;

    private GJK3DShape Target_ShapeA;

    private GJK3DShape Target_ShapeB;



    void Start()
    {
        Target_ShapeA = new GJK3DShape(Target_1.transform, Target_1.mesh);
        Target_ShapeB = new GJK3DShape(Target_2.transform, Target_2.mesh);
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.P)) {

            if (GJK3DEngine.IsContract(Target_ShapeA, Target_ShapeB))
            {
                Debug.Log("<color=red>发生碰撞！</color>");
            }
            else {
                Debug.Log("<color=green>没有碰撞接触！</color>");
            }
        }
        if (Input.GetKeyDown(KeyCode.I)) 
        {
            Target_ShapeA.DebugVertices();
        }
        if (Input.GetKeyDown(KeyCode.O))
        {
            Target_ShapeB.DebugVertices();
        }

        if (GJK3DEngine.IsContract(Target_ShapeA, Target_ShapeB))
        {
            Debug.Log("<color=red>发生碰撞！</color>");
        }
        else
        {
            Debug.Log("<color=green>没有碰撞接触！</color>");
        }
    }
}
